﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DSLisp.Runtime;
using DSLisp.Infrastructure;

namespace DSLisp.AST
{
    //used to hold snapshots of non local values inside a lambda
    //binding identifiers to values at the time of the lambda declaration
    public class SymbolSnapshotNode : SymbolNode 
    {
        internal Symbol staticSymbol;
        public Symbol StaticSymbol 
        { 
            get 
            {
                return staticSymbol;
            }
        }
        


        public override object Eval(StackFrame stackFrame)
        {            
            return staticSymbol.Value;

        }

        public override object Clone(CloneInfo info)
        {
            SymbolSnapshotNode clone = new SymbolSnapshotNode();
            BaseClone(clone);
            clone.staticSymbol = new Symbol();
            clone.StaticSymbol.Value = this.StaticSymbol.Value;
            clone.Name = this.Name;
            return clone;
        }
    }
}
